package org.opentcs.strategies.basic.dispatching.phase.assignment;

import jakarta.inject.Inject;
import org.opentcs.components.kernel.services.InternalPlantModelService;
import org.opentcs.drivers.vehicle.VehicleController;
import org.opentcs.drivers.vehicle.VehicleControllerPool;
import org.opentcs.strategies.basic.dispatching.AssignmentCandidate;
import org.opentcs.strategies.basic.scheduling.modules.SameDirectionBlockModule;


public class BlockController {

  private final VehicleControllerPool vehicleControllerPool;
  private final SameDirectionBlockModule sameDirectionBlockModule;

  @Inject
  public BlockController(VehicleControllerPool vehicleControllerPool,
                         SameDirectionBlockModule sameDirectionBlockModule,
                         InternalPlantModelService plantModelService) {
    this.vehicleControllerPool = vehicleControllerPool;
    this.sameDirectionBlockModule = sameDirectionBlockModule;
  }


  public boolean isCanChangeInBlock(AssignmentCandidate candidate) {
    VehicleController vehicleController = vehicleControllerPool.getVehicleController(candidate.getVehicle().getName());
    return sameDirectionBlockModule.canChangeDirInBLock(vehicleController);
  }

}
